import { createRouter, createWebHashHistory } from "vue-router";

// Components
import HomeView from "@/pages/HomePage.vue";
/**
 * Types
 */
import type { RouteRecordRaw } from "vue-router";
// Error
import error from "@/components/Error.vue";

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "首页",
      component: HomeView,
    },
    {
      path: "/about",
      name: "about",
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import("@/pages/AboutPage.vue"),
    },
    {
      path: "/:pathMatch(.*)*",
      // redirect: "/",
      name: "NotFound",
      component: error,
    },
  ] as RouteRecordRaw[],
});

export default router;
